package com.ruoyi.project.charging.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.charging.domain.CChargingProject;
import com.ruoyi.project.charging.service.ICChargingProjectService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 充电项目数据Controller
 * 
 * @author Yaoxuan Mo
 * @date 2025-07-28
 */
@RestController
@RequestMapping("/charging/project")
public class CChargingProjectController extends BaseController
{
    @Autowired
    private ICChargingProjectService cChargingProjectService;

    /**
     * 查询充电项目数据列表
     */
    @PreAuthorize("@ss.hasPermi('charging:project:list')")
    @GetMapping("/list")
    public TableDataInfo list(CChargingProject cChargingProject)
    {
        startPage();
        List<CChargingProject> list = cChargingProjectService.selectCChargingProjectList(cChargingProject);
        return getDataTable(list);
    }

    /**
     * 导出充电项目数据列表
     */
    @PreAuthorize("@ss.hasPermi('charging:project:export')")
    @Log(title = "充电项目数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CChargingProject cChargingProject)
    {
        List<CChargingProject> list = cChargingProjectService.selectCChargingProjectList(cChargingProject);
        ExcelUtil<CChargingProject> util = new ExcelUtil<CChargingProject>(CChargingProject.class);
        util.exportExcel(response, list, "充电项目数据数据");
    }

    /**
     * 获取充电项目数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('charging:project:query')")
    @GetMapping(value = "/{projectId}")
    public AjaxResult getInfo(@PathVariable("projectId") Long projectId)
    {
        return success(cChargingProjectService.selectCChargingProjectByProjectId(projectId));
    }

    /**
     * 新增充电项目数据
     */
    @PreAuthorize("@ss.hasPermi('charging:project:add')")
    @Log(title = "充电项目数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CChargingProject cChargingProject)
    {
        return toAjax(cChargingProjectService.insertCChargingProject(cChargingProject));
    }

    /**
     * 修改充电项目数据
     */
    @PreAuthorize("@ss.hasPermi('charging:project:edit')")
    @Log(title = "充电项目数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CChargingProject cChargingProject)
    {
        return toAjax(cChargingProjectService.updateCChargingProject(cChargingProject));
    }

    /**
     * 删除充电项目数据
     */
    @PreAuthorize("@ss.hasPermi('charging:project:remove')")
    @Log(title = "充电项目数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{projectIds}")
    public AjaxResult remove(@PathVariable Long[] projectIds)
    {
        return toAjax(cChargingProjectService.deleteCChargingProjectByProjectIds(projectIds));
    }
}
